from pathlib import Path

# # 硬编程 不同系统间，路径差异导致这段代码不可使用
# path = '/Users/ayuliao/Desktop/'
# print(f'硬编程的路径: {path}')
#
# path2 = Path().joinpath('Users', 'ayuliao', 'Desktop')
# print(f'软编程的路径: {path2}')

# p = Path()
# print(p.resolve())

def findallpyfile(dir):
    # 递归的形式遍历
    for p in dir.rglob('*.py'):
        # 深度
        depth = len(p.relative_to(dir).parts)
        print(p.name, depth)

# findallpyfile(Path.cwd())

from collections import Counter

gen = []
for i in Path.cwd().iterdir():
    gen.append(i.suffix)

print(Counter(gen))

gen = (i.suffix for i in Path.cwd().iterdir())
print(Counter(gen))